home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp48hor2 / cnflib.doc < prev    next >
Text File  |  1995-03-31  |  13KB  |  453 lines

  1. CNFLIB.DIR contains the source of a library which is made using parts of the 
  2. startup and the config suppressor libraries. You will find the documentations 
  3. for both below. Just d/l CNFLIB.DIR and excute SETUP... 
  4.  
  5.  
  6. BEGIN_DOC startup_dm.doc 
  7. Hi all. 
  8.  
  9. My HP48 often warmstarts (installed a new/changed lib, crash or ON-C). 
  10. Every time I have to restart the permanent 5-level stack display, switch 
  11. to the VAR menu and (after a memory lost) restore the flag settings. 
  12.  
  13. My first attemp creating an autostart to avoid this was a simple execution 
  14. of the cfg program (see below) during a library configuration. Fine, my 
  15. general settings (flags, last cmds) are restored every warmstart, but 
  16. switching to the VAR menu during config-time makes no sense; the user 
  17. interface (alias system outer loop - SOL) which handles menus isn't 
  18. initialized ... 
  19.  
  20. It's neccessary for the cfg and especialy for stk5 (again, see below) that 
  21. the SOL is allready initialized upon start. 
  22.  
  23. Maybe it's possible to set up an control-alarm from a library config routine, 
  24. but the time needed to execute all library configs is very variable, and I 
  25. don't know what happens if the alarm comes up during a library config without 
  26. an installed SOL. 
  27.  
  28. While examining the warmstart code, I recognize that the initialization of 
  29. the SOL is the last step in the procedure (starting at addr. #469Ah) and ... 
  30. it's called via RAM -- means: the RAM cell FIRSTPROC (a supported entry !) 
  31. contains the address of the SOL init routine which is jumped to (StartupProc 
  32. - another supported entry !). 
  33.  
  34. With this information in mind I create the library below; a short CODE ob at 
  35. the end of $CONFIG writes the address of StartUp into FIRSTPROC. StartUp 
  36. sets up the control alarm (which will call cfg and dispatches to stk5 1s 
  37. later), then dispatches to StartupProc (from the CODE ob at the end). 
  38.  
  39. To build this library you need to have RPL:2.1 (or higher), a reference 
  40. table and <-LIB->:1.2 (or higher) installed. USRLIB WON'T WORK. 
  41.  
  42. More documentation can be found in the source listing below. 
  43.  
  44. Enjoy, 
  45.         8-Detlef 
  46. END_DOC 
  47.  
  48. BEGIN_RPL strup_dm.rpl 
  49. %%HP: T(3); 
  50. DIR 
  51.  
  52. @ SETUP ( --> ) 
  53. @       Assumes, that RPL:2.1/2.2 and <-LIB->:1.2 are installed before d/l. 
  54. @       Generates an untiteled library with the id 1112. You can switch 
  55. @       to its menu with 1112 MENU. 
  56. @       DON'T USE USRLIB TO BUILD THE LIB !!! 
  57.  
  58.   SETUP 
  59.     \<< 
  60.       VARS 
  61.       'TMP' DUP CRDIR EVAL 
  62.       "\010" 1 DISP 
  63.       \-> v 
  64.       \<< 
  65.         v SIZE 2 
  66.         FOR x 
  67.           v x GET 
  68.           DUP 1 DISP 
  69.           DUP RCL \->RPL $\-> 
  70.           SWAP STO 
  71.           -1 
  72.         STEP 
  73.       \>> 
  74.       { cfg stk5 } $visible STO 
  75.       1112 $romid STO 
  76.       "Building Library" 1 DISP 
  77.       D\->LIB 
  78.       "Cleanup\010\010\010\010\010" 1 DISP 
  79.       UPDIR 'TMP' PGDIR 
  80.     \>> 
  81.  
  82. @ $CONFIG 
  83. @       Of special interest is the CODE object at the end. It writes 
  84. @       the address of StartUp into FIRSTPROC, so StartUp is called 
  85. @       instead of StartupProc when all config codes are passed. 
  86. @       You may change the whole code expect the CODE ob and its position. 
  87. @       This $CONFIG does no autoattach ... it's not neccessary. 
  88. @       DON'T EXECUTE THIS PROGRAM DIRECTLY !!! 
  89.  
  90.   $CONFIG 
  91. "($CONFIG) 
  92. :: 
  93.  (Start your code here) 
  94.  
  95.  FIFTYSIX TestSysFlag 
  96.  DUP IT       (BEEP off) 
  97.  ::           (Switch on) 
  98.   FIFTYSIX ClrSysFlag 
  99.  ; 
  100.  FIFTEEN # 190 
  101.  TWENTYFOUR # 12C 
  102.  setbeep setbeep 
  103.  IT           (BEEP was off) 
  104.  ::           (Switch off) 
  105.   FIFTYSIX SetSysFlag 
  106.  ; 
  107.  FORTYONE TestSysFlag (24 hr) 
  108.  ?SKIP                (Set def. contrast) 
  109.   (The following CODE ob in HP terms: 
  110.    CODE 
  111.     AD0EX 
  112.     D0=[5]  #101 contr.reg. 
  113.     LC[2]   #08  contr.val. 
  114.     DAT0=C  B 
  115.     D0=A 
  116.     GOVLNG  =Loop 
  117.    ENDCODE) 
  118.   CODE 1B 1321B10100318014C1308D465D2 
  119.   (Insert your value  ^^ here [reversed!], 
  120.    #03 <= x <= #13, HP def. #0B) 
  121.  
  122.  (Finish your code here) 
  123.  
  124.  (The following CODE ob in HP terms: 
  125.   CODE 
  126.    LC[5]  #2F   Offset DOCODE/StartUp 
  127.    A=A+C  A     rem.: A = Ob ptr 
  128.    LC[5]  =FIRSTPROC 
  129.    CD0EX 
  130.    DAT0=A A 
  131.    D0=C 
  132.    GOVLNG =Loop 
  133.   ENDCODE) 
  134.  CODE 20 34F2000CA34E76071361401348D465D2 
  135. ;" 
  136.  
  137. @ cfg 
  138. @       My personally configuration. Change it to your own. Note: the 
  139. @       HXS flags are in reversed order. 
  140.  
  141.   cfg 
  142. "(cfg, \-> ) 
  143. :: 
  144.  CK0 
  145.  HOMEDIR               (Go HOME) 
  146.  { 
  147.   %9600 
  148.   %0 %1 %1 %1 %3 
  149.  } 
  150.  ' ID IOPAR ?STO_HERE  (Std IOPAR) 
  151.  %2 InitMenu%          (Set VAR menu) 
  152.  PTR 5386E             (Last cmd on) 
  153.  PTR 538CE             (Last stack on) 
  154.  { 
  155.   HXS 10 0FF1481800308803 
  156.   HXS 10 0000000000000000 
  157.  } 
  158.  xSTOF                 (Std flags) 
  159. ;" 
  160.  
  161. @ stk5 
  162. @       The famous permanent 5-level stack. I remove the CODE ob's, the 
  163. @       lambda usage and add the exit feature via clearing flag -14. 
  164. @       If you want to purge the lib, execute -14 CF first. 
  165.  
  166.   stk5 
  167. "(stk5) 
  168. :: 
  169.  CK0 
  170.  FOURTEEN SetSysFlag 
  171.  BEGIN 
  172.   AtUserStack 
  173.   SysMenuCheck 
  174.   DA2aOK?NOTIT 
  175.   :: 
  176.    KEYINBUFFER? NOT 
  177.    PTR 38FB9 
  178.    ORcase 
  179.    :: 
  180.     TOADISP 
  181.     PTR 38FB9 
  182.     PTR 53A90 
  183.     case PTR 39BF3 
  184.     PTR 3958B 
  185.     PTR 39FD2 
  186.     ERRSET 
  187.     :: 
  188.      PTR 39F6F #1+ 
  189.      DUP#0=csDROP 
  190.      ONESWAP 
  191.      ZERO_DO 
  192.       ISTOP-INDEX 
  193.       OVERDUP #3+ 
  194.       PTR 44197 
  195.       :: 
  196.        :: 
  197.         DUP NOT?SEMI 
  198.         3PICK #1<> 
  199.         ?SEMI 
  200.         PTR 39F56 
  201.         NOT?SEMI 
  202.         OVER PTR 39E0F 
  203.         NOT?SEMI 
  204.         PTR 39FB0 
  205.         ?SEMI 
  206.         DROPSWAPDROP 
  207.         OVERSWAP 
  208.         NULL{} 
  209.         SWAP3PICK 
  210.         ZERO_DO 
  211.          SWAPOVER 
  212.          PTR 39E78 
  213.          INDEX@ 
  214.          #0=ITE 
  215.           PTR 39EB9 
  216.           PTR 39F23 
  217.          5UNROLL 
  218.          DUPNULLCOMP? 
  219.          IT PTR 39EE1 
  220.         SWAPLOOP 
  221.         2DROP DUPDUP 
  222.         #3+ UNROLL 
  223.         ZERO_DO 
  224.          ISTOP-INDEX 
  225.          #1+ROLL 
  226.          OVER 
  227.          ISTOP@ #- 
  228.          INDEX@ #+ #3+ 
  229.          DISPN 
  230.         LOOP 
  231.         RDROP 
  232.         DROPDUP FOUR 
  233.         #<> ?SEMI 
  234.         PTR 3957A 
  235.        ; 
  236.        ITE 
  237.         PTR 39DE2 
  238.         #:>$ 
  239.        SWAP #2+ DISPN 
  240.        ONE 
  241.       ; 
  242.       SWAP#1+SWAP 
  243.      +LOOP 
  244.      DROP 
  245.     ; 
  246.     ERRTRAP 
  247.      PTR 39C61 
  248.     SetDA2aValid 
  249.    ; 
  250.    PTR 394A5 
  251.   ; 
  252.   DA1OK?NOTIT 
  253.   PTR 3959C 
  254.   DA2bOK?NOTIT 
  255.   DispEditLine 
  256.   DA3OK?NOTIT 
  257.   ?DispMenu 
  258.   ClrDAsOK 
  259.   PTR 4203C 
  260.   ERRSET 
  261.    DoKeyOb 
  262.   ERRTRAP 
  263.    PTR 38728 
  264.   FOURTEEN TestSysFlag 
  265.  NOT_UNTIL 
  266. ;" 
  267.  
  268. @ StartUp 
  269. @       THIS COMMAND MUST BE HIDDEN AND IT MUST BE THE LAST VARIABLE IN 
  270. @       THE DIRECTORY. Because of the method D->LIB buils a library this 
  271. @       will guarantee that StartUp follows directly the config code. 
  272. @       The offset needed for calculating the address which is stored 
  273. @       into FIRSTPROC by the CODE ob in $CONFIG is hard coded. 
  274. @       StartUp is called via FIRSTPROC from the warmstart routine. 
  275. @       Again you may change the whole code (e.g. to a password gateway) 
  276. @       except the CODE ob at the end and its position. But remember, 
  277. @       the SOL isn't initialized yet. 
  278. @       DON'T EXECUTE THIS PROGRAM DIRECTLY !!! 
  279.  
  280.   StartUp 
  281. "(StartUp) 
  282. :: 
  283.  :: 
  284.   (Start own code here) 
  285.  
  286.   DATE              (Today) 
  287.   TOD % .0001 %HMS+ (Now + 1s) 
  288.   ' 
  289.   :: 
  290.    PTR E724         (Purge Alarm,%\->) 
  291.    ID cfg           (call cfg) 
  292.    COLA ID stk5     (dispatch to stk5) 
  293.   ; 
  294.   THREE{}N 
  295.   PTR E54D          (Install Alarm,{}\->%) 
  296.   DROP              (Returned alm idx) 
  297.  
  298.   (Finish own code here) 
  299.  ; 
  300.  ERRTRAP            (In case of error..) 
  301.  :: 
  302.   ONE SetUserFlag   (Signal error) 
  303.  ; 
  304.  DEPTH DUP#0=ITE 
  305.   DROP              (Stack empty) 
  306.  ::                 (Junk on stk) 
  307.   NDROP             (remove junk) 
  308.   TWO SetUserFlag   (signal junk) 
  309.  ; 
  310.  
  311.  (The following CODE ob in HP terms: 
  312.   CODE 
  313.    D0=[5]  [=StartupProc]+5 
  314.    GOVLNG  =Loop 
  315.   ENDCODE) 
  316.  CODE E 1B395838D465D2 
  317. ;" 
  318.  
  319. END 
  320. END_RPL 
  321.  
  322.  
  323. BEGIN_DOC cfgsupr_dm.doc 
  324.  
  325. Hi all. 
  326.  
  327.         A few days ago I got a library which conifg code crashes if no HP 
  328. EQLIB is installed. If a config code errors during a warmstart, you have 
  329. to hard reset the HP48 with the paperclip followed by 'NO'... I don't own 
  330. a EQLIB, but I wanted to split the damned thing using <-LIB-> (a library 
  331. must be installed for doing this). 
  332.  
  333.         Unfortunately I never saw a copy of the config aborter listed in 
  334. J.K.Horns library list (ID 14, IMHO the lib I needed), so I sat down and 
  335. played a while with <-LIB->, <-RPL-> and libraries containing only the 
  336. following config code: 
  337.  
  338. %%HP: T(3); 
  339. ":: 
  340.  (The following CODE ob in HP terms: 
  341.   CODE 
  342.    GOSBVL =SAVPTR 
  343.    C=B    A       C[A] = R 
  344.    D0=C           D0   = R 
  345.    D0=D0- 5       D0   = ->->caller 
  346.    A=DAT0 A       A[A] = ->caller 
  347.    GOVLNG =PUSH#ALOOP 
  348.   ENDCODE) 
  349.  CODE 19 8FB9760D91341841428DC7530 
  350.  DEPTH {}N 
  351.  DUP ' ID CfgStk 
  352.  PTR 2E9E6 (SysSTO) 
  353.  INCOMPDROP DROP 
  354. ;" 
  355.  
  356. This lead to two interesting things: 
  357.      1. During execution of a config code the stack contains a meta object 
  358.         made from library IDs (BINTS) of libraries pending for its config 
  359.         code execution. 
  360.         The meta ob looks like: 
  361.             #lowest_id ... #highest_id #no_of_ids 
  362.  
  363.      2. Each config code is called by the sys-RPL routine starting at 
  364.         address # 2216h: 
  365.         ::  DUP 
  366.             ZERO_DO 
  367.                 pullrev         ( obn .. ob1 #n --> obn-1 .. ob1 #n-1 obn ) 
  368.                 PTR 8143        ( #LibId --> conf_code TRUE | FALSE ) 
  369.                 IT EVAL 
  370.             LOOP 
  371.             DROP 
  372.         ; 
  373.  
  374.         Somewhere in the warmstart code the meta object of all existing 
  375. library IDs is generated and #2216 is called; it pulls each ID and checks 
  376. the associated library for a config code; if it's present, it's called. 
  377.  
  378.         With this information in mind I made the library below, a config code 
  379. suppressor. Its config code searches the home directory for the variable 
  380. 'NoCfg', if it's nonexistent or don't contain a list (usally of real numbers) 
  381. or a real number (which is internally converted to a list), no further action 
  382. take place. If a library ID found in 'NoCfg' also appears in the meta object 
  383. during config, it's removed from the meta object and the library is attached 
  384. to the home directory. Finaly the code resets the LOOP parameters of the 
  385. #2216 routine. 
  386.  
  387.         I gave this library the lowest unused ID possible (4), so no config 
  388. code of any moveable library have been executed when the lib 4 config code 
  389. takes over control. 
  390.  
  391.         Below you'll find the source directory of lib 4 (along with the 
  392. binaries); to build it you need to have the <-RPL-> and <-LIB-> libraries 
  393. beeing installed. Install/deinstall it like any other library. 
  394.  
  395. Where lib 4 is usefull for ? 
  396.       - if you get a new library, add its ID to the NoCfg variable to be 
  397.         shure it never gets control until you know what it do to your HP48. 
  398.       - if you have installed some noisy libraries (loud, long and ugly 
  399.         config codes), add the IDs to NoCfg. 
  400.       - if you want to take a look at a library containing a unfriendly config 
  401.         code (copy/shareware protection or buggy) add its ID to NoCfg. 
  402.         Eg. If you copy the W&W Dis-Assembler (ID 1432 (reserved !) into a R/W 
  403.         port, you loose all memory upon the next warmstart ! Just add 1432 to 
  404.         NoCfg. 
  405.  
  406. On the other side there're libraries that *MUST* run their config codes to 
  407. work properly, e.g.: 
  408.       - the <-RPL-> library since version 3.0 
  409.       - HP41 emulator. It messes with the low-level port configuration. 
  410.         If its libraries are simply attached, it may crash the HP48 when 
  411.         trying to use the emulator. 
  412.       - most config autostarts (eg. ID 1112) are useless if their config 
  413.         code is suppressed. 
  414.       - et c. (maybe somebody make a complete list ?) 
  415.  
  416. Enjoy, 
  417.         8-Detlef 
  418.  
  419. END_DOC 
  420.  
  421. BEGIN_RPL cfgsupr_dm.rpl 
  422. %%HP: T(3); 
  423. DIR 
  424.   $ROMID # 4h        @ As low as possible... 
  425.   $CONFIG 
  426. ":: 
  427.  ' ID NoCfg Sys@ 
  428.  NOT?SEMI            (NoCfg not in HOME dir) 
  429.  DUPTYPEREAL? 
  430.  IT ONE{}N           (If %, embedd it in {}) 
  431.  DUPTYPELIST? 
  432.  NOTcaseDROP         (If not {}, leave) 
  433.  SWAPDUP             ( meta[LIDs] \-> #n1 .. #nn {} #n ) 
  434.  ZERO_DO 
  435.   ISTOP-INDEX        ( \-> .. {} #n #x' ) 
  436.   #2+ DUP#1+ ROLL    ( \-> .. {} #n #x #lid ) 
  437.   4PICKOVER UNCOERCE ( \-> .. {} #n #x #lid {} %lid ) 
  438.   EQUALPOSCOMP       ( \-> .. {} #n #x #lid #pos ) 
  439.   #0=ITE 
  440.   ::                 (LID not in {},) 
  441.    SWAP UNROLL       (push it back) 
  442.   ; 
  443.   ::                 (LID in {},) 
  444.    TOSRRP DROP#1-    (just attach it) 
  445.   ; 
  446.  LOOP 
  447.  SWAPDROP 
  448.  ZERO INDEXSTO       (Reset config LOOP) 
  449.  DUP#1+ ISTOPSTO 
  450. ;" 
  451. END 
  452. END_RPL 
  453.